package com.tdtxdcxm.ruralcommunity.slice;


import com.tdtxdcxm.ruralcommunity.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;


public class StartPage extends AbilitySlice implements Component.ClickedListener{
    private Boolean toanotherslice = false;
    private Text logreg_title;
    private Button logreg_wantlog,logreg_wantreg;
    private void initLogAndRegComponent(){
        logreg_title = (Text) findComponentById(ResourceTable.Id_logreg_title);
        logreg_wantlog = (Button) findComponentById(ResourceTable.Id_logreg_wantlog);
        logreg_wantreg = (Button) findComponentById(ResourceTable.Id_logreg_wantreg);

        logreg_wantreg.setClickedListener(this);
        logreg_wantlog.setClickedListener(this);
    }
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_loginandregisterpage);

        initLogAndRegComponent();
    }
    @Override
    public void onActive() {
        super.onActive();
        logreg_title.setText("欢迎来到文化乡道");
    }
    @Override
    protected void onInactive() {
        super.onInactive();
        if(toanotherslice == true){
            terminate();
        }
    }
    @Override
    protected void onBackground() {
        super.onBackground();
    }
    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
    @Override
    protected void onStop() {
        super.onStop();
    }
    @Override
    public void onClick(Component component) {
        if(component == logreg_wantlog){
            present(new LoginSlice(),new Intent());
            toanotherslice = true;
        }
        if(component == logreg_wantreg){
            present(new RegisterSlice(),new Intent());
            toanotherslice = true;
        }
    }
}